package com.ykg.service.impl;

import com.ykg.dto.ListDTO;
import com.ykg.mapper.ListMapper;
import com.ykg.mapper.NoticeMapper;
import com.ykg.pojo.ListCharge;
import com.ykg.pojo.NoticeLetter;
import com.ykg.service.IAgentService;
import com.ykg.service.IDTOService;
import com.ykg.util.CreateIdUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * TODO
 * 类(接口)：
 * Created on 2021/6/23 9:04.
 *
 * @Author: zetong
 * @Description:
 */
@Service
public class AgentServiceImpl implements IAgentService {

    @Autowired
    private ListMapper listMapper;

    @Autowired
    private NoticeMapper noticeMapper;




    @Override
    /**
    * TODO
    *  港务局审核卸货清单
    * @params：
        @param listId
    * @return {@link int}
    * @Author: laobian
    * @Date: 7:52 2021/6/24
    */
    public int checkListCharge(String listId){
        int state = 1;//公司待接收状态
        int result1 = listMapper.updateListState(listId,state);
        //生成未审核状态的通知单
        CreateIdUtil createIdUtil= new CreateIdUtil();
        String noticeId = createIdUtil.creatNoticeLetterId();
        ListCharge listCharge = listMapper.findListById(listId);
        int state1 = 0;//通知单在业务大厅待审核
        //生成待处理的通知单
        NoticeLetter noticeLetter = new NoticeLetter(noticeId,new Long(listCharge.getShipId()),
                listCharge.getListId(),new Date(), new Long(listCharge.getOwnerId()),state1);
        int result2 = noticeMapper.addNotice(noticeLetter);
        return result1+result2;
    }
}
